import 'package:flutter/material.dart';
import 'package:news_demo/View/Home/Widget/NewsItmeWidget.dart';

import '../../../Pojo/News_Itme_Pojo.dart';

class News extends StatefulWidget {
  const News({Key? key}) : super(key: key);

  @override
  State<News> createState() => _IndexState();
}

class _IndexState extends State<News> {
  final List<NewsItmePojo> ListArray = [
    NewsItmePojo(
      "http://n.sinaimg.cn/default/1_img/upload/3933d981/674/w899h575/20210130/b066-kiksqxh1091087.jpg",
      "2023/1/2",
      "许家印：今年是关键年，恒大一定能偿还各种债务、化解风险，一定能涅槃重生。",
      "某某日报",
      "1",
    ),
    NewsItmePojo(
      "http://n.sinaimg.cn/default/1_img/upload/3933d981/674/w899h575/20210130/b066-kiksqxh1091087.jpg",
      "2023/1/2",
      "许家印：今年是关键年，恒大一定能偿还各种债务、化解风险，一定能涅槃重生。",
      "某某日报",
      "1",
    ),
    NewsItmePojo(
      "http://n.sinaimg.cn/default/1_img/upload/3933d981/674/w899h575/20210130/b066-kiksqxh1091087.jpg",
      "2023/1/2",
      "许家印：今年是关键年，恒大一定能偿还各种债务、化解风险，一定能涅槃重生。",
      "某某日报",
      "1",
    ),
    NewsItmePojo(
      "http://n.sinaimg.cn/default/1_img/upload/3933d981/674/w899h575/20210130/b066-kiksqxh1091087.jpg",
      "2023/1/2",
      "许家印：今年是关键年，恒大一定能偿还各种债务、化解风险，一定能涅槃重生。",
      "某某日报",
      "1",
    ),
    NewsItmePojo(
      "http://n.sinaimg.cn/default/1_img/upload/3933d981/674/w899h575/20210130/b066-kiksqxh1091087.jpg",
      "2023/1/2",
      "许家印：今年是关键年，恒大一定能偿还各种债务、化解风险，一定能涅槃重生。",
      "某某日报",
      "1",
    ),
  ];

  final List<Widget> NewsListArray=[];
  
  //更新热点新闻
  void _UpDateNewsHost(){
    print("更新热点新闻");
  }

  @override
  void initState() {
    // TODO: implement initState
    for(int i=0;i<ListArray.length;i++){
      NewsListArray.add(NewsItme(NIP: ListArray[i]));
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0.0,
        backgroundColor: Colors.white,
        title: Text(
          "今日热点新闻",
          style: TextStyle(fontSize: 18, color: Colors.black),
        ),
        actions: [
          Container(
            margin: EdgeInsets.fromLTRB(0, 0, 14, 0),
            child: GestureDetector(
              onTap: () {
                _UpDateNewsHost();
              },
              child: Icon(
                Icons.cached,
                size: 26,
                color: Colors.black,
              ),
            ),
          )
        ],
      ),
      body: SingleChildScrollView(
          scrollDirection: Axis.vertical,
          child: Container(
            padding: EdgeInsets.fromLTRB(0,0,0,8),
              width: double.infinity,
              color: Colors.black12,
              child: NewsRestList(ItmeList: NewsListArray,)
              // child: ,
              )),
    );
  }
}

class NewsRestList extends StatelessWidget {
  final List<Widget> ItmeList;
  const NewsRestList({Key? key ,required this.ItmeList}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: ItmeList,
    );
  }
}
